package basics.day16.second;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFormatDemo {
    public static void main(String[] args) throws Exception {
        fun_1();
        fun_2();
    }

    public static void fun_1() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        String formatDate = sdf.format(date);
        System.out.println(formatDate); // 2019-02-18 15:49:17
    }

    public static void fun_2() throws Exception {
//        Date date = new Date(231412341283412L);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse("2019-02-18 15:49:17");
        System.out.println(date);
        System.out.println(sdf.format(date));
    }
}
